//
//  LoginViewController.m
//  app1
//
//  Created by 张领瑞 on 2017/8/29.
//  Copyright © 2017年 ShiFeiEr. All rights reserved.
//

#import "LoginViewController.h"
#import "RegisterViewController.h"
#import "UIViewController+CAAnimate.h"
#import "UIViewController+UIStoryboard.h"
#import "UIViewController+TapGesture.h"
#import "PrefixHeader.pch"

@interface LoginViewController ()


@property (weak, nonatomic) IBOutlet UITextField *passWordTF;//密码输入
@end

@implementation LoginViewController


#pragma mark 登陆BT
- (IBAction)loginAction:(id)sender {
    
    if (![self.phoneNumTF isMobilePhoneNumber]) {//判断电话号码
        [self presentDefaultAlertViewWithMessage:@"请输入正确的电话号码!"];
        return;
    }
    if (self.passWordTF.text.length < 6 || self.passWordTF.text.length > 16) {
        [self presentDefaultAlertViewWithMessage:@"您的密码必须在6-16位之间！"];
        return;
    }
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:self.phoneNumTF.text forKey:@"phoneNumber"];
    NSString *MD5Str = [UIViewController MD5ForLower32Bate:self.passWordTF.text];
    [dic setObject:MD5Str forKey:@"password"];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:kLOGINURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSLog(@"登陆成功---%@",responseObject);
        //登陆成功跳转到首页
        UIViewController *vc = [self viewControllerInMStoryboardWithName:@"Main" WithIdentifier:@"TabBarC"];
        [self presentViewController:vc animated:YES completion:nil];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"登陆失败～～～～%@",error.description);
        [self presentDefaultAlertViewWithMessage:@"登陆失败"];
        
    }];
}
#pragma mark 跳转注册界面bt
- (IBAction)jumpToRegisteVC:(id)sender {
    
   /*
    UIViewController *regVC = [self viewControllerInMStoryboardWithName:@"Main" WithIdentifier:@"RegisterViewController"];
    [self transitionAnimate];
    
    [self presentViewController:regVC animated:YES completion:nil];
    */
}
#pragma mark跳转至找回密码的验证码界面
- (IBAction)jumpToResetPWDVC:(id)sender {
    
   /* UIViewController *regVC = [self viewControllerInMStoryboardWithName:@"Main" WithIdentifier:@"GetCodeNav"];
    [self transitionAnimate];
    [self presentViewController:regVC animated:NO completion:nil];
    */
}

#pragma mark qq第三方登陆
- (IBAction)qqLoginAction:(id)sender {
}
#pragma mark weixin第三方登陆
- (IBAction)weiXinLoginAction:(id)sender {
}
#pragma mark weibo第三方登陆
- (IBAction)weiBoLoginAction:(id)sender {
}

- (void)viewDidLoad {
    [super viewDidLoad];
  [self addTapGestureForViewControllerToRecoverKeyboard];//添加手势回收键盘
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}





/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
